<?php

namespace app\admin\controller;

use app\admin\controller\AdminBaseController;
use app\admin\model\ActionLog;
use app\admin\service\ActionLogService;
use think\annotation\Inject;
use think\App;

class ActionLogController extends AdminBaseController {

    #[Inject]
    protected ActionLogService $service;

    #[Inject]
    protected ActionLog $model;
    /**
     * @throws \Exception
     */
    public function index() {
        $data = $this->getParams();
        //当前是否为关联查询
        //设置过滤方法
        $extendQueryHelper = $this->buildparams();
        $list = $this->service->getActionLogList($extendQueryHelper, $data);
//        foreach ($list as $row) {
//
//        }
        return $this->success($list);
    }

    /**
     * @throws \Exception
     */
    public function read() {
        $data = $this->getParams();
        $res = $this->service->getActionLogItem($data);
        return $this->returnSuccess($res);
    }

    public function delete($id) {
        $res = $this->service->delActionLogItem($id);
        return $this->returnSuccess($res);
    }

    public function clear(){
        $res = $this->service->clearActionLog();
        return $this->returnSuccess($res);
    }

}
